package com.countertack.dynamicinstrumentation;

import java.util.UUID;

import org.doublecloud.vi.vmware.guest.GuestFileDirector;
import org.doublecloud.vi.vmware.guest.GuestProcessDirector;

import sun.misc.UUDecoder;

import com.countertack.ssh.SSHManager;
import com.countertack.vmware.VMWareConnector;
import com.vmware.vim25.GuestProgramSpec;
import com.vmware.vim25.NamePasswordAuthentication;
import com.vmware.vim25.mo.GuestAuthManager;
import com.vmware.vim25.mo.GuestOperationsManager;
import com.vmware.vim25.mo.GuestProcessManager;
import com.vmware.vim25.mo.VirtualMachine;

public class RunningDosCommand {
	
	public static void main(String[] args) throws Exception{
		/*VMWareConnector vmc=new VMWareConnector("10.140.63.49");
		VirtualMachine vm=vmc.getVirtualMachineByname("Win7x86-McAfee-3");
		GuestProcessDirector progDir = new GuestProcessDirector(
				vm, "mahesh", "password1");
		String vmUser="mahesh";
		String uuid=UUID.randomUUID().toString();
		progDir.run(
				"C:\\Users\\" + vmUser + "\\cmd.exe",
				"/c ipconfig > c:\\Users\\"
						+ vmUser
						+ "\\vmwaretest1.txt && sc query && arp -a && echo \"hello world\" > c:\\Users\\mahesh\\smoketestfile"
						+ uuid
						+ ".txt && reg  add HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\smoketestkey_"
						+ uuid);
		*/
		
//		GuestOperationsManager gom=vmc.getOperationManager();
//		GuestAuthManager gam = gom.getAuthManager(vm);
//	    NamePasswordAuthentication npa = new NamePasswordAuthentication();
//	    npa.username = "user";
//	    npa.password = "password1";
//	    GuestProgramSpec spec = new GuestProgramSpec();
//	    spec.programPath = "C:\\Users\\user\\Desktop\\cmd.exe";
//	    spec.arguments = "\"ipconfig > vmtest.txt\"";
//	 
//	    GuestProcessManager gpm = gom.getProcessManager(vm);
//	    long pid = gpm.startProgramInGuest(npa, spec);
//	    System.out.println("pid: " + pid);
		
//	    GuestProcessDirector progDir = new GuestProcessDirector(vm, "user", "password1");
//	    
//	    progDir.run("C:\\Users\\user\\cmd.exe", "/c ipconfig > c:\\Users\\user\\vmwaretest1.txt");
		
		
//		GuestFileDirector dir=new GuestFileDirector(vm, "user", "password1");
//		dir.downloadFile("c:\\Windows\\System32\\cmd.exe", "c:\\Users\\user\\cmd.txt");
		
		
		SSHManager ssh=new SSHManager("root", "f00b@r", "10.150.100.118");
		
		ssh.connect();
	//ssh.returnCommandOutPut("ls /root");
	ssh.downloadFile("/var/log/flume-ng/flume-cmf-flume1-AGENT-s18.dev.countertack.com.log", "c:\\Users\\user");
		
		/*ssh.downloadFile("/opt/cloudera/parcels/Sentinel-1.0-176-unstable/opt/countertack/java/ct-jobs-1.0-SNAPSHOT.jar", "c:\\Users\\user");
		ssh.downloadFile("/opt/cloudera/parcels/Sentinel-1.0-176-unstable/opt/countertack/java/ct-schemas-1.0-SNAPSHOT.jar", "c:\\Users\\user");
		ssh.downloadFile("/opt/cloudera/parcels/Sentinel-1.0-176-unstable/opt/countertack/java/ct-udfs-1.0-SNAPSHOT.jar", "c:\\Users\\user");
		ssh.downloadFile("/opt/cloudera/parcels/Sentinel-1.0-176-unstable/opt/countertack/java/ct-turret-1.0-SNAPSHOT.jar", "c:\\Users\\user");*/
		//ssh.downloadFile("/root/extracted_files-0000001392619820262-0273038901temp.zip", "c:\\Users\\user");
		
		System.out.println("completed");
		
		//ssh.runCommand("scp -f /var/log/flume-ng/flume-cmf-flume1-AGENT-s13.dev.countertack.com.log rnaidu:hcl@123@10.140.62.45:/qa/diflume");
		
		//\\10.140.62.45\qa\diflume
		
	}

}
